package org.csu.small.controller.admin;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.csu.small.common.Constant;
import org.csu.small.common.UniformResponse;
import org.csu.small.service.IStatisticService;
import org.csu.small.utils.MessageUtil;
import org.csu.small.vo.StatisticVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @author Rambo
 * @date 2020-07-08 16:08
 */
@Controller
@RequestMapping("/manage/statistic/")
@Api(value = "API - StatisticController", description = "统计接口详情")
public class StatisticController {
    @Autowired
    IStatisticService statisticService;

    @GetMapping("base_count")
    @ResponseBody
    @ApiOperation(value = "用户、商品、订单总数")
    public UniformResponse<StatisticVO> getBaseCount(){
        UniformResponse<StatisticVO> response = statisticService.getBaseCount();
        return response;
    }

    @GetMapping("message_count")
    @ResponseBody
    @ApiOperation(value = "短信剩余条数")
    public UniformResponse<String> balance(){
        try {
            String balance = MessageUtil.balance();
            return UniformResponse.createForSuccess(balance);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return UniformResponse.createForError();
    }
}
